﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Cloudthentic.SSIS.Server.Configuration
{
    public class SsisPackageConfigurationElementCollection : ConfigurationElementCollection
    {


        public void Add(SsisPackageConfigurationElement element)
        {
            base.BaseAdd(element);
        }

        protected override ConfigurationElement CreateNewElement()
        {
            SsisPackageConfigurationElement element = new SsisPackageConfigurationElement();
            return element;
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            SsisPackageConfigurationElement ssisElement = element as SsisPackageConfigurationElement;
            if (ssisElement == null) throw new NullReferenceException("SsisPackageConfigurationElementCollection::GetElementKey(ConfigurationElement element)");

            return ssisElement.PackageName;
        }

        public SsisPackageConfigurationElement this[string packageName]
        {
            get
            {
                SsisPackageConfigurationElement elemet = base.BaseGet(packageName) as SsisPackageConfigurationElement;
                if (elemet == null) throw new NullReferenceException("Cannot resolve the package element");
                return elemet;
            }

        }
    

    }
}
